import axios from '../lib/http'

// 轮播图实体接口
export interface Carousel {
  id: number
  goodId: number
  showOrder: number
}

// 分页查询轮播图列表
export const getCarousels = async (params?: {
  current?: number
  pageSize?: number
}) => {
  const res = await axios.get('/carousel', { params })
  return res.data
}

// 获取单个轮播图详情
export const getCarousel = async (id: number) => {
  const res = await axios.get(`/carousel/${id}`)
  return res.data
}

// 创建轮播图
export const createCarousel = async (data: Carousel) => {
  const res = await axios.post('/carousel', data)
  return res.data
}

// 更新轮播图
export const updateCarousel = async (data: Carousel) => {
  const res = await axios.put('/carousel', data)
  return res.data
}

// 删除轮播图
export const deleteCarousels = async (idList: number[]) => {
  const res = await axios.delete('/carousel', {
    params: { idList }
  })
  return res.data
}

// 获取启用的轮播图列表（用于首页展示）
export const getActiveCarousels = async () => {
  const res = await axios.get('/carousel/active')
  return res.data
}